<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <title>费用报销列表</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <link rel="stylesheet" href="/dist/plugins/fixedTable/fixed-table.css"/>
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=e9c5bb62">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=66b457d6">
    <style>
        .bgOne {
            color: black;
        }

        .bgTwo {
            color: red;
        }

        .bgThree {
            color: #9d9d9d;
        }

        .fixed-table_body tr td {
            border-right: none;
            font-size: 12px;
            text-align: center;
            height: 24px;
            max-height: 24px;
            overflow: hidden;
        }

        .fixed-table_header tr th {
            border-right: none;
            background: yellow;
            font-weight: normal;
            font-size: 12px;
        }

        .fixed-table_body tr:nth-of-type(odd) {
            background: #F9F9F9;
        }

        .content {
            padding: 8px 8px 0 8px;
        }
    </style>
</head>
<body>
<section class="content" id="app" v-cloak="">
    <div class="div-td-content-more"><i></i></div>
    <iframe id="ifExprot" style="width:0px;height:0px;display: none;" frameborder="0"></iframe>
    <div style="height: 25px;margin-bottom: 10px;">
        <div class="pull-left" style="width: 120px;">
            <select id="selectCompany" class="form-control"
                    style="width: 100%;height: 25px;font-size: 12px;line-height: 25px;padding-top: 0px;padding-bottom: 0px;padding-left: 6px;"
                    v-model="searchParams.companyId">
                <option value="">请选择公司</option>
                <option v-for="item in companyList" v-bind:value="item.id">{{item.name}}</option>
            </select>
        </div>
        <div class="pull-left" style="width: 130px;margin-left: 10px;">
            <select id="selectCostName" class="form-control"
                    style="height: 25px;font-size: 12px;line-height: 25px;padding-top: 0px;padding-bottom: 0px;padding-left: 6px;"
                    v-model="searchParams.meetType">
                <option value="">请选择会议类型</option>
                <option v-for="item in meetTypeList" :value="item.value">{{item.text}}</option>
            </select>
        </div>
        <input class="pull-left form-control pull-left input-sm" type="text" v-model="searchParams.beginTime"
               @focus="showDatePicker($event)" placeholder="请选择开始时间" style="width: 150px;margin-left: 10px;">
        <input class="pull-left form-control pull-left input-sm" type="text" v-model="searchParams.endTime"
               @focus="endDatePicker($event)" placeholder="请选择结束时间" style="width: 150px;">
        <input type="text" placeholder="会议主题" class="form-control pull-left input-sm"
               style="width: 150px; margin-left: 10px;" v-model="searchParams.meetTitle">
        <!-- <input type="text" placeholder="费用名称" class="form-control pull-left input-sm"
                style="width: 150px; margin-left: 10px;" v-model="searchParams.costSmallName" id="txtCostSmallName">-->
        <button type="button" class="btn oaBtn btn-sm pull-left" style="margin-left: 10px;" @click="getList()">查询
        </button>
        <input type="button" class="btn oaBtn btn-sm pull-right" value="新建会议"
               @click="goDetail('edit','0')"/>
    </div>
    <div class="box-body no-padding iframeHMeet" id="scrollDiv">
        <div id="progress" class="wyui-progress"></div>
        <div class="fixed-table-box head-fixed" style="height: 100%;">
            <div class="fixed-table_header-wraper">
                <table class="fixed-table_header" cellspacing="0" cellpadding="0" border="0">
                    <!--<table class="table table-hover  text-center" style="margin-top: 20px;">-->
                    <thead>
                    <tr>
                        <th style="width:40px;">
                            <div class="table-cells">序号</div>
                        </th>
                        <th style="width:120px">
                            <div class="table-cells">公司</div>
                        </th>
                        <th style="width:120px">
                            <div class="table-cells">部门</div>
                        </th>
                        <th style="width:160px">
                            <div class="table-cells">会议类型</div>
                        </th>
                        <th>
                            <div class="table-cells">会议主题</div>
                        </th>
                        <th style="width:120px">
                            <div class="table-cells">创建人</div>
                        </th>
                        <th style="width:90px">
                            <div class="table-cells">创建时间</div>
                        </th>
                        <th style="width:120px">
                            <div class="table-cells">操作</div>
                        </th>
                        <th id="tdMore">
                            <div class="table-cells"></div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
            <div class="fixed-table_body-wraper iframeYKFixed" id="divMain" style="height: 100%;">
                <table class="fixed-table_body table-hover" cellspacing="0" cellpadding="0" border="0"
                       style="width: 100%;" id="tableMain">
                    <tbody>
                    <tr v-for="(item,i) in list">
                        <td style="width:40px;">{{i+1}}</td>
                        <td style="width:120px;">{{item.companyName}}</td>
                        <td style="width:120px;">{{item.departName}}</td>
                        <td style="width:160px;">{{item.meetType}}</td>
                        <td style="text-align: left">
                            <a href="javascript:void(0);"
                               @click="goDetail('look',item) "
                               style="color:#2a8cec;cursor: pointer;text-align: center">{{item.meetTitle}}</a>
                        </td>
                        <td style="width:120px;">
                            <span class="oa-name">{{item.createUserName}}</span>
                        </td>
                        <td style="width:90px;">
                            {{formatDate(item.createTime)}}
                        </td>
                        <td style="width: 120px">
                            <a href="javascript:void(0);" v-if="item.createUserId ==currentUser.id"
                               @click="goDetail('edit',item) "
                               style="color:#2a8cec;cursor: pointer;text-align: center">编辑</a>
                            <a href="javascript:void(0);" v-else @click="goDetail('look',item) "
                               style="color:#2a8cec;cursor: pointer;text-align: center">查看</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="oa-pager text-center" style="margin-top: 5px;">
        共
        <span id="allCount"> 0 </span>条记录&nbsp;&nbsp;&nbsp;
        <span id="nowPage"> 1 </span>/<span id="allPage">1</span>&nbsp;&nbsp;&nbsp;
        <span class="oa-pager-button" id="first">首页</span>
        <span class="oa-pager-button" id="prev">上一页</span>
        <span class="oa-pager-button" id="next">下一页</span>
        <span class="oa-pager-button" id="last">尾页</span>
    </div>
    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>

<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=0b5caf39"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=0c4d95a9"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script src="/dist/plugins/fixedTable/fixed-table.js"></script>
<script>
    $(function () {
        $("body").on("click", ".lineOne", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script type="text/javascript">
    function refresh() {
        $.wyui.page.getByPage();
    }

    console.log(urlConfig);
    var app = new Vue({
        el: '#app',
        data: {
            currentUser: getCurrentUser(),
            list: [],
            companyMorningFlag: false,
            companyWeekFlag: false,
            departWeekFlag: false,
            week: [],
            companyList: [],
            meetTypeList: [
                {text: '公司晨会', value: '公司晨会'},
                {text: '公司周例会', value: '公司周例会'},
                {text: '部门周例会', value: '部门周例会'},
            ],
            searchParams: {
                meetTitle: "",
                meetType: "",
                companyId: "",
                beginTime: "",
                endTime: "",
                createUserId: getCurrentUser().id,
            }

        },
        watch: {
            isCheckedAll: function (isCheck) {
                if (isCheck) {
                    for (var i = 0; i < this.list.length; i++) {
                        var item = this.list[i];
                        //console.log("1111111111111111"+JSON.stringify(item))
                        if (item.bxState == 0 || item.bxState == 1) {
                            item.checked = this.isCheckedAll;
                            this.selectIds.push(item.id);
                        }
                    }

                } else {
                    this.selectIds = [];
                    for (var i = 0; i < this.list.length; i++) {
                        var item = this.list[i];
                        item.checked = this.isCheckedAll;
                    }
                }
            }
        },
        methods: {
            showDatePicker: function (e) {
                var that = this;
                WdatePicker({
                    onpicked: function (dp) {
                        that.searchParams.beginTime = dp.cal.getNewDateStr();
                        return true;
                    },
                    onclearing: function () {
                        that.searchParams.beginTime = '';
                    }
                    //dateFmt:'yyyy-MM-dd HH:mm'
                });
                $(e.target).blur();
            },
            endDatePicker: function (e) {
                var that = this;
                WdatePicker({
                    onpicked: function (dp) {
                        that.searchParams.endTime = dp.cal.getNewDateStr();
                        return true;
                    },
                    onclearing: function () {
                        that.searchParams.endTime = '';
                    }
                });
                $(e.target).blur();
            },
            getNowDate: function () {
                var now = new Date();
                var year = now.getFullYear();
                var month = (now.getMonth() + 1).toString();
                var day = (now.getDate()).toString();
                var hour = (now.getHours()).toString();
                var minute = (now.getMinutes()).toString();
                var second = (now.getSeconds()).toString();
                if (month.length == 1) {
                    month = "0" + month;
                }
                if (day.length == 1) {
                    day = "0" + day;
                }
                if (hour.length == 1) {
                    hour = "0" + hour;
                }
                if (minute.length == 1) {
                    minute = "0" + minute;
                }
                if (second.length == 1) {
                    second = "0" + second;
                }
                var dateTime = year + "-" + month + "-" + day;
                return dateTime;
            },
            getNowDateFormat: function (date) {
                if (date) {
                    var now = new Date(date);
                    var year = now.getFullYear();
                    var month = (now.getMonth() + 1).toString();
                    var day = (now.getDate()).toString();
                    var hour = (now.getHours()).toString();
                    var minute = (now.getMinutes()).toString();
                    var second = (now.getSeconds()).toString();
                    if (month.length == 1) {
                        month = "0" + month;
                    }
                    if (day.length == 1) {
                        day = "0" + day;
                    }
                    if (hour.length == 1) {
                        hour = "0" + hour;
                    }
                    if (minute.length == 1) {
                        minute = "0" + minute;
                    }
                    if (second.length == 1) {
                        second = "0" + second;
                    }
                    var dateTime = year + "年" + month + "月" + day + "日";
                    return dateTime;
                }
            },
            changeFlag: function () {
                var that = this;
                var nowDate = that.getNowDate();
                //判断今天有没有建立晨会
                for (var i = 0; i < that.list.length; i++) {
                    if (nowDate == that.list[i].reportDate && that.list[i].meetType == '公司晨会'
                        && that.list[i].companyName == that.currentUser.companyName
                    ) {
                        that.companyMorningFlag = true;
                    }
                }
                //判断本周有没有创建周列会

                for (var i = 0; i < that.list.length; i++) {
                    if (that.week.indexOf(that.list[i].reportDate) != -1 && that.list[i].meetType == '公司周例会'
                        && that.list[i].companyName == that.currentUser.companyName
                    ) {
                        that.companyWeekFlag = true;
                    }
                    if (that.week.indexOf(that.list[i].reportDate) != -1 && that.list[i].meetType == '部门周例会'
                        && that.list[i].companyName == that.currentUser.companyName
                        && that.list[i].departName == that.currentUser.departName
                    ) {
                        that.departWeekFlag = true;
                    }
                }
                console.log(that.companyMorningFlag, that.companyWeekFlag, that.departWeekFlag)
            },
            goDetail: function (type, item) {
                var that = this;
                that.changeFlag();
                if (item == '0') {
                    var H = $(window).height() - 50;
                    top.$.dialog({
                        content: 'url:/page/meet/meetType.html?companyMorningFlag=' + that.companyMorningFlag + '&companyWeekFlag=' + that.companyWeekFlag + '&departWeekFlag=' + that.departWeekFlag,
                        title: '会议类型',
                        width: 300,
                        height: 200,
                        max: false,
                        min: false,
                        lock: true
                    });
                } else {
                    top.closeTabByPageId("hyxq")
                    top.addTabs({
                        id: "hyxq",
                        title: '会议详情',
                        close: true,
                        url: 'meet/detail.html?pageType=' + type + '&id=' + item.id
                    });
                }

            },
            getTime: function (n) {
                var now = new Date();
                var year = now.getFullYear();
//因为月份是从0开始的,所以获取这个月的月份数要加1才行
                var month = now.getMonth() + 1;
                var date = now.getDate();
                var day = now.getDay();
                console.log(month, date, day);
//判断是否为周日,如果不是的话,就让今天的day-1(例如星期二就是2-1)
                if (day != 0) {
                    n = n + (day - 1);
                } else {
                    n = n + day;
                }
                if (day) {
//这个判断是为了解决跨年的问题
                    if (month > 1) {
                        month = month;
                    }
//这个判断是为了解决跨年的问题,月份是从0开始的
                    else {
                        year = year - 1;
                        month = 12;
                    }
                }
                now.setDate(now.getDate() - n);
                year = now.getFullYear();
                month = now.getMonth() + 1;
                date = now.getDate();
                console.log(n);
                s = year + "-" + (month < 10 ? ('0' + month) : month) + "-" + (date < 10 ? ('0' + date) : date);

                /***参数都是以周一为基准的***/
                return s;
            },
            getList: function (e) {
                var that = this;
                $.wyui.page.queryParams.requestPage = 1;
                if (that.searchParams.userName == "") {
                    that.searchParams.userId = ""
                }
                var data = {
                    'companyId': that.searchParams.companyId,
                    'beginTime': that.searchParams.beginTime,
                    'endTime': that.searchParams.endTime,
                    'meetType': that.searchParams.meetType,
                    'meetTitle': that.searchParams.meetTitle,
                };
                $.extend($.wyui.page.queryParams, data);
                console.log($.wyui.page.queryParams);
                $.wyui.page.getByPage();
            },
            //日期格式
            formatDate: function (now) {
//                return  NewDate(now).Format(TimeFormat.middle)
                return new Date(now).Format(TimeFormat.pcList);
            },
            getHeight: function () {
                var allHeight = $("#divMain").height()
                var tableHeight = $("#tableMain").height()
                console.log(allHeight,tableHeight)
                var flag = allHeight >= tableHeight ? true : false
                console.log(flag)
                if (flag) {
                    $('#tdMore').css('width', '0px');
                } else {
                    $('#tdMore').css('width', '17px');
                }
            },
        },
        mounted: function () {
            var that = this;
            var H = $(window).height();
            $(".iframeHMeet").height(H - 80);
            var now = new Date();
            var year = now.getFullYear();
            var month = now.getMonth() + 1;
            var date = now.getDate();
            var day = now.getDay();
            if (day == 0) {
                for (var i = 0; i <= 6; i++) {
                    console.log(that.getTime(i));
                    that.week.push(that.getTime(i))
                }
            } else {
                for (var i = -6; i <= 0; i++) {
                    console.log(that.getTime(i));
                    that.week.push(that.getTime(i))
                }
            }
            console.log(that.week)

            $.wyui.postMethod(urlConfig.system.company.getCompanyByUserId, {userId: currentUser.id}, function (r) {
                console.log(r);
                that.companyList = r;
            });
        }
    });
    $(window).resize(function () {
        var H = $(window).height();
        $(".iframeHMeet").height(H - 73);
    })
    $.wyui.page.dataUrl = server.ip + urlConfig.meet.meet.getListInfo;
    $.wyui.page.queryParams.pageType = $.wyui.page.urlParams.pageType;
    $.wyui.page.queryParams = {
        requestPage: 1,
        pageSize: 100
    }
    $.extend($.wyui.page.queryParams);
    $.wyui.page.getByPage_callback = function (records) {
        console.log(records)
        app.list = records;
        setTimeout(function () {
            app.getHeight();
        },200)
        document.getElementById("scrollDiv").scrollTop = 0;
    };
    $.extend($.wyui.page.queryParams, app.searchParams);
    $.wyui.page.getByPage_scroll_callback = function (list) {
        if (list.length < 30) {
            isLoad = false;
        } else {
            for (var i = 0; i < list.length; i++) {
                app.list.push(list[i]);
            }
            isLoad = true;
        }
    };
    $(function () {
        $("#txtCoster").autoComplete({
            url: server.ip + urlConfig.system.user.getCosterTop10ByNameUserRight,
            render: function (users, panel) {
                console.log("users=" + users);
                if (users) {
                    for (var i = 0; i < users.length; i++) {
                        $("<li></li>").data("autoComplete",
                            users[i]).html("<a>" + users[i].name + "&nbsp;&nbsp;&nbsp;" +
                            "(" + "&nbsp;" + users[i].companyName + "-" + users[i].departName + "-" + users[i].roleName + "&nbsp;" + ") " + "</a>")
                            .appendTo(panel);
                    }
                }
            },
            selected: function (user) {
                console.log(user);
                app.searchParams.userId = user.id;
                app.searchParams.userName = user.name;
            },
            extraParams: {userId: getCurrentUser().id},
            height: 210,
            width: 300
        });
    }),
        $(function () {
                $("#txtCostSmallName").autoComplete({
                    url: server.ip + "/wreportCost/getCosterTop10ByCostName.json",
                    render: function (users, panel) {
                        console.log("users=" + users);
                        if (users) {
                            for (var i = 0; i < users.length; i++) {
                                $("<li></li>").data("autoComplete",
                                    users[i]).html("<a>" + users[i].costName + "</a>")
                                    .appendTo(panel);
                            }
                        }
                    },
                    selected: function (user) {
                        console.log(user);
                        app.searchParams.costSmallName = user.costName;
                    },
                    height: 210,
                    width: 300
                });
            },
            Vue.directive('line-inserted', {
                inserted: function (el, binding) {
                    console.log(el);
                    var lineIndex = binding.value;
                    renderLines(el, lineIndex);
                }
            })
        );

    function selectAll() {
        var isCheck = $("#sel_1").is(':checked');  //获得全选复选框是否选中
        $("input[type='checkbox']").each(function () {
            this.checked = isCheck;       //循环赋值给每个复选框是否选中
        });
    };

</script>

<script>
    /************************滚动加载******************************/
    var divscroll = document.getElementById('scrollDiv');

    function divScroll() {
        var wholeHeight = divscroll.scrollHeight;
        var scrollTop = divscroll.scrollTop;
        var divHeight = divscroll.clientHeight;
        console.log(scrollTop + divHeight, wholeHeight)
        if (scrollTop + divHeight >= wholeHeight - 2) {
//            alert('滚动到底部了！');
            if (isLoad) {
                isLoad = false;
                setTimeout($.wyui.page.getByPage("scroll"), 1000);

            }

            //这里写动态加载的逻辑，比如Ajax请求后端返回下一个页面的内容
        }

    }

    divscroll.onscroll = divScroll;
</script>
<script>
    //初始化FixedTable
    $(".fixed-table-box").fixedTable();
</script>
</body>
</html>